package com.eschool.beans;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;

import org.primefaces.model.DualListModel;

import test.TestCourseConverter;

import com.eschool.model.Course;

@ManagedBean(name="pickListBean")
@ViewScoped
public class CoursePickListBean {

	private DualListModel<Course> courses;
	
	public CoursePickListBean() {
		
		List<Course> target = new ArrayList<Course>();
		courses = new DualListModel<Course>(TestCourseConverter.courseDB, target);
	}

	public DualListModel<Course> getCourses() {
		return courses;
	}

	public void setCourses(DualListModel<Course> courses) {
		this.courses = courses;
	}

	public String performAction(){
		
		for (Iterator iterator = courses.getTarget().iterator(); iterator.hasNext();) {
			Course course = (Course) iterator.next();
			System.out.println("Title" + course.getTitle() + "    Hours Per Week: " + course.getHoursPerWeek());
		}
		
		return "";
	}
}
                    